﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using KitBuilder.ManagerComponent;
using NHibernate;
using NHibernate.Cfg;
using System.Reflection;
using KitBuilder.DataAccess;

namespace KitBuilder
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void treeViewItem2_Selected(object sender, RoutedEventArgs e)
        {

        }

        private void treeViewItem1_Selected(object sender, RoutedEventArgs e)
        {
            
        }

        private void StockControlItem_Selected(object sender, RoutedEventArgs e)
        {
            /*
            Button B1 = new Button(), B2 = new Button(), B3 = new Button();
            B1.Content = "Hello";
            B2.Content = "First";
            // Now you can set more properties like height, width, margin etc...
            contentPanel.Children.Add(B1);
            contentPanel.Children.Add(B2);
            */
            
            StockControl sc = new StockControl();
            contentPanel.Children.Add(sc);

            sc.stockItemList.ItemsSource = LoadCollectionData();
              /*  Stock stock1 = new Stock();
            stock1.StockID = 1;
            stock1.Name = "iphone 4s";
            stock1.Code = "ip4s";
            stock1.StockIn = 5;
            stock1.StockOut = 2;
            */

            /*
            test t = new test();
            t.ID = 114;
            t.Name = "SmAxlL";
            
            using (ISession session = NHADO.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(t);
                    
                    transaction.Commit();
                }
                Console.WriteLine("Saved stock to the database");
            }
             * */
        }

        private List<Stock> LoadCollectionData()
        {
            List<Stock> stockitems = new List<Stock>();
            stockitems.Add(new Stock()
            {
                StockID = 2,
                Code = "hello",
                Name = "Mahesh Chand",
                StockIn = 12,
            });
            stockitems.Add(new Stock()
            {
                StockID = 3,
                Code = "hello3",
                Name = "Mahesh 3Chand",
                StockIn = 13,
            });
            return stockitems;
        }

        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {

        }

    }
}
